construct-cli: severity-tagged diagnostics — CLI Standard v1.1.0 compliance - #36
Conversation
Implements the diagnostics spec (references/diagnostics.md, PR #35): - New output/diagnostic.rs: Severity ladder (Info < Ok < Warn < Error, §18.2.1 tags), Diagnostic type emitting single-line {"diagnostic":{...}} envelopes in machine mode and [TAG]-first human rendering, gated by the severity floor on Context (--quiet → errors only, agent env → warn+, default → ok+, --verbose → info+). Errors (AppError) never consult the floor. - error.rs human render: error:/hint: → [ERROR] tag + indented hint:, tag carried in the colorless branch too (color is never the sole carrier of meaning). - mode.rs: warn_tui_fallback deleted — resolve() now returns the fallback reason and main emits a TUI_FALLBACK warn diagnostic after Context exists (no more raw JSON on a human TTY; drops the non-spec fell_back_to field). FORCE_COLOR now checked before NO_COLOR so it overrides it (was inverted vs its own comment and the spec). - theme.rs migrated from the grandfathered v1.33 six-token palette to the eleven Steelbore 2 §11.1 role tokens (this is the "next minor release" the grandfathering clause named); render.rs and tui/mod.rs remapped per tui-explore.md §3. - sync.rs nix progress passthrough gated by the info floor; ship.rs oversized-description hint and tui/mod.rs fallback hint made paste-test-clean runnable commands. - Tests: floor table, envelope shape/single-line/hint-omission, tag presence with and without color, FORCE_COLOR-over-NO_COLOR, agent-env explore fallback parses as a warn diagnostic, --quiet suppresses the fallback but never errors. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ac79d7c8ae
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| 5, | ||
| format!("SKILL.md description exceeds the {DESCRIPTION_CAP}-character cap: {detail}"), | ||
| format!("$EDITOR {first}/SKILL.md # trim the `description` frontmatter field"), | ||
| format!("python3 .githooks/check-description-length.py {first}/SKILL.md"), |
There was a problem hiding this comment.
Make the description-cap hint use the selected repo
When construct skill ship --repo /path/to/clone is invoked from outside that clone—a supported use case—this hint searches the caller's current directory for both .githooks/check-description-length.py and the skill, so pasting it fails instead of providing the promised runnable recovery command. Build both paths from repo (and quote them safely) so the hint works independently of the invocation directory.
AGENTS.md reference: construct-cli/AGENTS.md:L57-L60
Useful? React with 👍 / 👎.
What
Brings
construct-cliinto compliance with the diagnostics spec added in #35 (CLI Standard v1.1.0,references/diagnostics.md) — the reference implementation of severity-tagged, dual-audience error/feedback messages.New
src/output/diagnostic.rsSeverityladder (Info < Ok < Warn < Error) with the §18.2.1 tags[INFO]/[OK]/[WARN]/[ERROR].Diagnostictype: machine mode emits a single-line{"diagnostic":{severity, code, message, hint?, timestamp, command, …}}envelope on stderr; human mode renders[TAG] message+ indentedhint:, colored via theme tokens with the tag surviving colorless output.Context:--quiet→ errors only; agent env (AI_AGENT/AGENT) →warn+; default →ok+;--verbose→info+. Errors (AppError) never consult the floor.Fixes
warn_tui_fallbackused to print raw JSON unconditionally — even on a human TTY — in the deprecated{"warning":{…}}shape with a non-specfell_back_tofield and no hint. Nowmode::resolvereturns the fallback reason andmainemits a properTUI_FALLBACKwarn diagnostic (specific reason in thereasonextension, runnableconstruct skill find --jsonhint), honoring mode and floor.FORCE_COLORprecedence: the chain checkedNO_COLORfirst, soFORCE_COLORcould never override it — contradicting both its own comment and the spec. Reordered (matches force-color.org and CLI Standard v1.1.0 — diagnostic severity ladder, machine envelope, unified rendering #35's §6 fix); extracted as a purecolor_env_decisionwith table tests.error:/indentedhint:→ the unified[ERROR]+hint:layout; the colorless branch now carries the tag too (§18.2.1: color is never the sole carrier of meaning).ship's oversized-description hint ($EDITOR … # trim…) →python3 .githooks/check-description-length.py <skill>/SKILL.md; the TUI error hint's inline comment removed.syncnix passthrough gated by theinfofloor instead of a barectx.verbosecheck.Theme migration (§11.1)
theme.rsmoves from the grandfathered v1.33 six-token palette (which had no warning color distinct from error) to the eleven Steelbore 2 role tokens — this release is the "next minor release" the grandfathering clause named.render.rsand the TUI remapped pertui-explore.md§3 (labels/borders →structure, values →foreground, marks/selection →success, active/attention →accent).Sample output
Verification
cargo test(56 tests, including new floor-table, envelope-shape, tag-survival, FORCE_COLOR-override, agent-env-fallback, and quiet-suppression tests),cargo clippy --all-targets -- -D warnings,cargo fmt --check— all green locally. Manual smoke of the error path and explore fallback under piped/agent/quiet conditions matches the spec.Sequencing note: independent of #35 at the code level, but reviews best after it — the spec sections cited here are introduced there.
🤖 Generated with Claude Code